﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
	static void Main(string[] args)
	{
	    DataTable dt = ExcuteDataTable();
	    foreach (DataRow item in dt.Rows)
	    {
		Console.WriteLine(item[0]);
	    }
	    DataSet ds = new DataSet();
	    ds = dt.DataSet;


	    Console.Read();
	}
	public static DataTable ExcuteDataTable()
	{
	    string connString = "Data Source=120.25.59.199,2525;Initial Catalog=icsoft_new联机优卡特测试;User ID=sa;Password=JOCAT123456";
	    string sql = "select count(*) from ryxx";
	    SqlDataAdapter sad = new SqlDataAdapter();
	    using (SqlConnection conn = new SqlConnection(connString))
	    {
		conn.Open();
		SqlDataAdapter sd = new SqlDataAdapter(sql,conn);
		DataTable dt = new DataTable();
		sd.Fill(dt);
		conn.Close();
		return dt;
	    }
	}
    }
}
